package com.holyant.goods.enums;

public enum SkuPriceCloseFlagEnum {
    ON(0, "未停用"),
    OFF(1, "已停用");

    private final Integer code;
    private final String name;

    SkuPriceCloseFlagEnum(Integer code, String name)
    {
        this.code = code;
        this.name = name;
    }

    public Integer getCode()
    {
        return code;
    }

    public String getName()
    {
        return name;
    }

    public static String getNameByCode(Integer code) {
        for (SkuPriceCloseFlagEnum item : SkuPriceCloseFlagEnum.values()) {
            if (item.getCode().equals(code)) {
                return item.getName();
            }
        }
        return null;
    }

    public static Integer getCodeByName(String name) {
        for (SkuPriceCloseFlagEnum item : SkuPriceCloseFlagEnum.values()) {
            if (item.getName().equals(name)) {
                return item.code;
            }
        }
        return null;
    }

    public static SkuPriceCloseFlagEnum parse(Integer code) {
        for (SkuPriceCloseFlagEnum item : SkuPriceCloseFlagEnum.values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        return null;
    }

    public static SkuPriceCloseFlagEnum parseByName(String name) {
        for (SkuPriceCloseFlagEnum item : SkuPriceCloseFlagEnum.values()) {
            if (item.getName().equals(name)) {
                return item;
            }
        }
        return null;
    }
}
